package cn.sdormitory.controller;

import cn.sdormitory.academic.entity.ClsPracticeInfo;
import cn.sdormitory.academic.entity.ClsPracticeResult;
import cn.sdormitory.common.api.CommonPage;
import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.controller.vos.ParentQueryStudentInfoVo;
import cn.sdormitory.exam.vo.ExamResultInfoAppVo;
import cn.sdormitory.service.AppParentService;
import cn.sdormitory.smartclass.vo.ClassDvAppVo;
import cn.sdormitory.smartdor.entity.StudentTrajectory;
import cn.sdormitory.smartdor.vo.SdAttenceAppVo;
import cn.sdormitory.violative.entity.ParentAppViolationPatrol;
import cn.sdormitory.workflow.entity.ViolationApply;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author : yy
 * @date: 2024/11/2 15:05
 * @description:
 */
@RestController
@RequestMapping("/app/parent")
public class AppParentController {
    @Resource
    AppParentService appParentService;

    @PostMapping("/getParenChildTrajectory")
    public CommonResult<CommonPage<StudentTrajectory>> getParenChildTrajectory(@RequestBody ParentQueryStudentInfoVo queryVo) {
        IPage<StudentTrajectory> page = appParentService.getParenChildTrajectory(queryVo);
        return CommonResult.success(CommonPage.restPage(page));
    }
    
    @GetMapping("/getStudentTrajectoryByStudentId")
    public CommonResult<StudentTrajectory> getStudentTrajectory(@RequestParam("studentId") String studentId,
                                                                @RequestParam("faceTime") String faceTime) {
        StudentTrajectory studentTrajectory = appParentService.getStudentTrajectory(studentId, faceTime);
        return CommonResult.success(studentTrajectory);
    }
    
    @GetMapping("/getStudentDorAttendance")
    public CommonResult<SdAttenceAppVo> getStudentDorAttendance(@RequestParam("studentId") String studentId,
                                                                @RequestParam("datetime") String datetime) {
        SdAttenceAppVo sdAttenceAppVo = appParentService.getStudentDorAttendance(studentId, datetime);
        return CommonResult.success(sdAttenceAppVo);
    }

    @GetMapping("/getParenChildScore")
    public CommonResult<List<ExamResultInfoAppVo>> getParenChildScore(@RequestParam("studentId") Long studentId){
        List<ExamResultInfoAppVo> list = appParentService.getParenChildScore(studentId);
        if(list.isEmpty()){
            return CommonResult.failed("该学生暂无考试成绩!");
        }else {
            return CommonResult.success(list);
        }
    }
    
    @GetMapping("/getClsPractice")
    public CommonResult<List<ClsPracticeInfo>> getClsPractice(@RequestParam("studentId") Long studentId){
        List<ClsPracticeInfo> list = appParentService.getClsPractice(studentId);
        if(list.isEmpty()){
            return CommonResult.failed("该学生暂无考试成绩!");
        }else {
            return CommonResult.success(list);
        }
    }

    @GetMapping("/getParenChildDv")
    public CommonResult<List<ParentAppViolationPatrol>> getParenChildDv(@RequestParam("studentId") Long studentId){
        List<ParentAppViolationPatrol> list = appParentService.getParenChildDv(studentId);
        if(list.isEmpty()){
            return CommonResult.failed("该学生无违纪信息!");
        }else {
            return CommonResult.success(list);
        }
    }

    @PostMapping("/getParenChildDorAttendance")
    public CommonResult<CommonPage<SdAttenceAppVo>> getParenChildDorAttendance(@RequestBody ParentQueryStudentInfoVo queryVo){
        IPage<SdAttenceAppVo> list = appParentService.getParenChildDorAttendance(queryVo);
        return CommonResult.success(CommonPage.restPage(list));
    }
}
